/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.gitee.minimalismstyle.fresh.flowable.api.feign

import org.springframework.web.bind.annotation.*
import com.gitee.minimalismstyle.fresh.flowable.api.model.*
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.flowable.api.annotation.FlowableClient
import com.gitee.minimalismstyle.fresh.flowable.api.config.FlowableFeignConfig
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.*

/**
 * ProcessInstances
 * @author maoxiaodong
 */
@FlowableClient(configuration = [FlowableFeignConfig::class])
interface ProcessInstancesApi {


    /**
     * The request body can contain all possible filters that can be used in the List process instances URL query. On top of these, it’s possible to provide an array of variables to include in the query, with their format described here.

    The general paging and sorting query-parameters can be used for this URL.
     */
    @PostMapping("/query/process-instances")
    fun queryProcessInstances(
        @RequestBody(required = false) body: ProcessInstanceQueryRequest?
    ): R<DataResponse<ProcessInstanceResponse>>

    /**
     * List process instances
     */
    @GetMapping("/runtime/process-instances")
    fun listProcessInstances(
        @RequestParam(name = "id", required = false) id: String?,
        @RequestParam(name = "name", required = false) name: String?,
        @RequestParam(name = "nameLike", required = false) nameLike: String?,
        @RequestParam(name = "nameLikeIgnoreCase", required = false) nameLikeIgnoreCase: String?,
        @RequestParam(name = "processDefinitionKey", required = false) processDefinitionKey: String?,
        @RequestParam(name = "processDefinitionId", required = false) processDefinitionId: String?,
        @RequestParam(name = "processDefinitionCategory", required = false) processDefinitionCategory: String?,
        @RequestParam(name = "processDefinitionVersion", required = false) processDefinitionVersion: Int?,
        @RequestParam(
            name = "processDefinitionEngineVersion",
            required = false
        ) processDefinitionEngineVersion: String?,
        @RequestParam(name = "businessKey", required = false) businessKey: String?,
        @RequestParam(name = "businessKeyLike", required = false) businessKeyLike: String?,
        @RequestParam(name = "startedBy", required = false) startedBy: String?,
        @RequestParam(name = "startedBefore", required = false) startedBefore: String?,
        @RequestParam(name = "startedAfter", required = false) startedAfter: String?,
        @RequestParam(name = "activeActivityId", required = false) activeActivityId: String?,
        @RequestParam(name = "involvedUser", required = false) involvedUser: String?,
        @RequestParam(name = "suspended", required = false) suspended: Boolean?,
        @RequestParam(name = "superProcessInstanceId", required = false) superProcessInstanceId: String?,
        @RequestParam(name = "subProcessInstanceId", required = false) subProcessInstanceId: String?,
        @RequestParam(name = "excludeSubprocesses", required = false) excludeSubprocesses: Boolean?,
        @RequestParam(name = "includeProcessVariables", required = false) includeProcessVariables: Boolean?,
        @RequestParam(name = "callbackId", required = false) callbackId: String?,
        @RequestParam(name = "callbackType", required = false) callbackType: String?,
        @RequestParam(name = "tenantId", required = false) tenantId: String?,
        @RequestParam(name = "tenantIdLike", required = false) tenantIdLike: String?,
        @RequestParam(name = "withoutTenantId", required = false) withoutTenantId: Boolean?,
        @RequestParam(name = "sort", required = false) sort: String?
    ): R<DataResponse<ProcessInstanceResponse>>

    /**
     * Note that also a *transientVariables* property is accepted as part of this json, that follows the same structure as the *variables* property.

    Only one of *processDefinitionId*, *processDefinitionKey* or *message* can be used in the request body.

    Parameters *businessKey*, *variables* and *tenantId* are optional.

    If tenantId is omitted, the default tenant will be used. More information about the variable format can be found in the REST variables section.

    Note that the variable-scope that is supplied is ignored, process-variables are always local.


     */
    @PostMapping("/runtime/process-instances")
    fun createProcessInstance(
        @RequestBody(required = false) body: ProcessInstanceCreateRequest?
    ): R<ProcessInstanceResponse>

    /**
     * Get a process instance
     */
    @GetMapping("/runtime/process-instances/{processInstanceId}")
    fun getProcessInstance(
        @PathVariable("processInstanceId") processInstanceId: String
    ): R<ProcessInstanceResponse>

    /**
     * Update process instance properties or execute an action on a process instance (body needs to contain an 'action' property for the latter).
     */
    @PutMapping("/runtime/process-instances/{processInstanceId}")
    fun updateProcessInstance(
        @PathVariable("processInstanceId") processInstanceId: String,
        @RequestBody(required = false) body: ProcessInstanceUpdateRequest?
    ): R<ProcessInstanceResponse>

    /**
     * Delete a process instance
     */
    @DeleteMapping("/runtime/process-instances/{processInstanceId}")
    fun deleteProcessInstance(
        @PathVariable("processInstanceId") processInstanceId: String,
        @RequestParam(name = "deleteReason", required = false) deleteReason: String?
    ): R<Any>

    /**
     * Change the state a process instance
     */
    @PostMapping("/runtime/process-instances/{processInstanceId}/change-state")
    fun changeActivityState(
        @PathVariable("processInstanceId") processInstanceId: String,
        @RequestBody(required = false) body: ExecutionChangeActivityStateRequest?
    ): R<Any>

    /**
     * Get diagram for a process instance
     */
    @GetMapping("/runtime/process-instances/{processInstanceId}/diagram")
    fun getProcessInstanceDiagram(
        @PathVariable("processInstanceId") processInstanceId: String
    ): R<Any>

    /**
     * Evaluate the conditions of a process instance
     */
    @PostMapping("/runtime/process-instances/{processInstanceId}/evaluate-conditions")
    fun evaluateConditions(
        @PathVariable("processInstanceId") processInstanceId: String
    ): R<Any>

    /**
     * Inject activity in a process instance
     */
    @PostMapping("/runtime/process-instances/{processInstanceId}/inject")
    fun injectActivityInProcessInstance(
        @PathVariable("processInstanceId") processInstanceId: String,
        @RequestBody(required = false) body: InjectActivityRequest?
    ): R<Any>

    /**
     * Migrate process instance
     */
    @PostMapping("/runtime/process-instances/{processInstanceId}/migrate")
    fun migrateProcessInstance(
        @PathVariable("processInstanceId") processInstanceId: String,
        @RequestBody(required = false) body: String?
    ): R<Any>
}